var videoToCanvas={
    src:[],//多个视频地址
    canvas:null,
    toCanvas:function() {
        if (videoToCanvas.showCanvas == null) {
            videoToCanvas.showCanvas = document.createElement('canvas');
        }
        if (videoToCanvas.canvas == null) {
            videoToCanvas.canvas = document.createElement('canvas');
            videoToCanvas.canvas.setAttribute("style","display:block");
        }
        var ctx = videoToCanvas.canvas.getContext('2d');
        for (var i = 0; i < videoToCanvas.src.length; i++) {
            var src = videoToCanvas.src[i];
            var video = document.createElement("video");
            video.setAttribute("id", "video");
            video.setAttribute("src", src);
            video.setAttribute("width", "640");
            video.muted=true;
            video.setAttribute("style","visibility:visible;width:640px !important;height:264px !important;");
            video.setAttribute("controls","controls");
            document.body.appendChild(video);
            video.oncanplay=function(){
                video.play();
            }
            videoToCanvas.canvas.width = video.offsetWidth;
            videoToCanvas.canvas.height = video.offsetHeight;
            video.setAttribute("style","display:block;width:640px !important;height:264px !important;");
            document.body.appendChild(videoToCanvas.canvas);

            var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
                window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;

            var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
            var draw=function(){
                ctx.drawImage(video, 0, 0, videoToCanvas.canvas.width, videoToCanvas.canvas.height);
                requestAnimationFrame(draw);
            };
            var startTime=0;
            var jq=function(){
                 video.setAttribute("src",src);
                startTime+=10;
                video.currentTime=startTime;
                setTimeout(function(){jq();},10000);
            }
            video.addEventListener('play', function () {
                setTimeout(function(){jq();},10000);
                draw();
            }, false);
        }


    }
};

